{{extend "layout_auth.html"}}

{{block content}}
<div class="row">
    <div class="col-md-4 col-md-offset-4">
        {{if result==-1:}}
        <div class="alert alert-warning alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            {{=message}}
        </div>
        {{pass}}
        <div class="login-panel panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">请注册</h3>
            </div>
            <div class="panel-body">
                <form role="form" action="/auth/register" method="post" class="form-horizontal">
                    <fieldset>
                        <div class="form-group">
                            <label  class="col-lg-3 control-label">用户名</label>
                            <div class="col-lg-9">
                                <input cj-required cj-range="[1,16]" class="form-control cj-validator" placeholder="用户名" name="txt-username" cj-name="用户名" type="text" autofocus>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-lg-3 control-label">真实姓名</label>
                            <div class="col-lg-9">
                                <input cj-required cj-range="[1,16]" class="form-control cj-validator" placeholder="真实姓名" name="txt-realname" cj-name="真实姓名" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-lg-3 control-label">密码</label>
                            <div class="col-lg-9">
                                <input cj-required cj-range="[6,16]"  class="form-control cj-validator txt-passwd" id="txt-passwd" placeholder="密码" cj-name="密码" type="password" value="">
                            </div>
                            <input type="hidden" name="txt-passwd" id="hid-passwd" />
                        </div>
                        <div class="form-group">
                            <label  class="col-lg-3 control-label">重复密码</label>
                            <div class="col-lg-9">
                                <input cj-required cj-range="[6,16]"  class="form-control cj-validator txt-passwd" placeholder="重复密码"  cj-name="重复密码" type="password" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-lg-3 control-label">电子邮箱</label>
                            <div class="col-lg-9">
                                <input cj-email class="form-control cj-validator" placeholder="电子邮箱" name="txt-email" cj-name="电子邮箱" type="text" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-lg-3 control-label">手机号</label>
                            <div class="col-lg-9">
                                <input cj-telephone class="form-control cj-validator" placeholder="手机号" name="txt-telephone" cj-name="手机号" type="text" cj-name="手机号" value="">
                            </div>
                        </div>
                        <button class="btn btn-success col-lg-6 col-lg-offset-3" id="btn-register" type="submit">注册</button>
                        <button class="btn btn-link" id="btn-back" type="button">返回</button>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
</div>
{{end}}

{{block js}}
<script src="{{=url_for_static('chujue-js/chujue_validate.js')}}"></script>
<script src="{{=url_for_static('MD5.js')}}"></script>
<script type="text/javascript">
    $(function()
      {
          $("#btn-register").click(function() {
              var validator = new Chujue_Validator();
              if (validator.validation(".cj-validator"))
              {
                  var md5 = MD5($("#txt-passwd").val());
                  $("#hid-passwd").val(md5);
                  return true;
              }
              return false;
          });

          $("#btn-back").click(function() {
              location.href = "/login";
          });
          
      });
</script>
{{end}}
